﻿<%@ Control Language="C#" AutoEventWireup="true" Codebehind="ucTrees.ascx.cs" Inherits="BaseSystem._System.UserControl.ucTrees" %>
<script type="text/javascript">
   <!--
   //<![CDATA[

function public_GetParentByTagName(element, tagName)
{
       var parent = element.parentNode;
       var upperTagName = tagName.toUpperCase();

       while (parent && (parent.tagName.toUpperCase() != upperTagName))
       {
         parent = parent.parentNode ? parent.parentNode : parent.parentElement;
       }
       return parent;
}


function setParentChecked(objNode)
{
       var objParentDiv = public_GetParentByTagName(objNode,"div");
       if(objParentDiv==null || objParentDiv == "undefined")
       {
         return;
       }
       var objID = objParentDiv.getAttribute("ID");
       objID = objID.substring(0,objID.indexOf("Nodes"));
       objID = objID+"CheckBox";
       var objParentCheckBox = document.getElementById(objID);
       if(objParentCheckBox==null || objParentCheckBox == "undefined")
       {
         return;
       }
       if(objParentCheckBox.tagName.toLowerCase() != "input" && objParentCheckBox.type == "checkbox")
       return;
       objParentCheckBox.checked = true;
       setParentChecked(objParentCheckBox);
}

function setChildUnChecked(divID)
{
       var objchild = divID.children;
       var count = objchild.length;
       for(var i=0;i <objchild.length;i++)
       {
         var tempObj = objchild[i];
         if(tempObj.tagName.toLowerCase() == "input" && tempObj.type == "checkbox")
         {
            tempObj.checked = false;
         }
         setChildUnChecked(tempObj);
       }
}


function setChildChecked(divID)
{
       var objchild = divID.children;
       var count = objchild.length;

       for(var i=0;i <objchild.length;i++)
       {
         var tempObj = objchild[i];
         if(tempObj.tagName.toLowerCase() =="input" && tempObj.type == "checkbox")
         {
            tempObj.checked = true;
         }
         setChildChecked(tempObj);
       }
}

//
function CheckEvent()
{

       var objNode = event.srcElement;

       if(objNode.tagName!="INPUT" || objNode.type!="checkbox")
       return;
       if(objNode.checked==true)
       {
         setParentChecked(objNode);
         var objID = objNode.getAttribute("ID");
         var objID = objID.substring(0,objID.indexOf("CheckBox"));
         var objParentDiv = document.getElementById(objID+"Nodes");
         if(objParentDiv==null || objParentDiv == "undefined")
         {
            return;
         }
         setChildChecked(objParentDiv);
       }
       else
       {
         var objID = objNode.getAttribute("ID");
         var objID = objID.substring(0,objID.indexOf("CheckBox"));
         var objParentDiv = document.getElementById(objID+"Nodes");
         if(objParentDiv==null || objParentDiv == "undefined")
         {
            return;
         }
         setChildUnChecked(objParentDiv);
       }
} 
   //]]>
	// -->
</script>

<style type="text/css">
<!--

.skin0{
position:absolute;
width:140px;
border:1px solid #598dd8;
background-color:#d7e3f6;
font-family:Verdana;
line-height:20px;
cursor:default;
font-size:14px;
z-index:100;
visibility:hidden;
}

.menuitems{
padding-left:10px;
padding-right:10px;
font-family:Verdana;
font-size:12px;
color:white;
}

.menuitems  a
{
    color:black;
    
}

.menuitems  a:hover
{
     text-decoration:underline;
}

-->
</style>

<script type="text/javascript">

function ShowPanel(value)
{
    $get('<%= hfValue.ClientID %>').value = value;
}

function Operation(obj)
{
    $get('<%=hfOperationValue.ClientID %>').value = obj;
    <%= Page.ClientScript.GetPostBackClientHyperlink(this.lnkOperation, "") %>;
}

function $get(obj)
{
    return document.getElementById(obj);
}

function SetValue(obj,value)
{
    var span=document.getElementsByTagName("span");
    for(var i=0;i<span.length;i++)
    {
        if(span.item(i).id.charAt(0) == "b")
        {
            span.item(i).style.backgroundColor = "#edf1f8";
        }   
    }
    obj.style.backgroundColor = '#edf1f8';
    $get('<%=spanID.ClientID %>').value = obj.id;
}

window.onload=function()
{
    if($get('<%=spanID.ClientID %>').value != "")
    {
        var backId= $get('<%=spanID.ClientID %>').value;
        if($get(backId) != null)
        {
            $get(backId).style.backgroundColor="black";
        }
    }
}

</script>

<asp:HiddenField ID="spanID" Value="" runat="server" />
<asp:HiddenField ID="hfValue" runat="server" />
<asp:HiddenField ID="hfOperationValue" runat="server" />
<asp:TreeView ID="trRoles" runat="server" ShowCheckBoxes="All" ShowLines="True" Width="172px"  CssClass="TreeViewStyle">
           <ParentNodeStyle CssClass="TreeViewParentNodeStyle" />
        <RootNodeStyle CssClass="TreeViewRootNodeStyle" />
        <NodeStyle CssClass="TreeViewNodeStyle" />
        <HoverNodeStyle CssClass="TreeViewHoverNodeStyle" />
        <SelectedNodeStyle CssClass="TreeViewSelectedNodeStyle" />
        <LeafNodeStyle CssClass="TreeViewLeafNodeStyle" />
</asp:TreeView>
<div id="Panel2" class="skin0" onMouseover="highlightie5(event)" onMouseout="lowlightie5(event)" onClick="jumptoie5(event)" >
    <div id="divOper" runat="server">
    </div>
</div>
<asp:LinkButton  ID="lnkOperation" runat="server" CssClass="menuitems" Text="F" Visible="False"
    OnClick="lnkOperation_Click" CausesValidation="False"></asp:LinkButton>
<span id="loadJs" runat="server"></span>


